<template>
    <div class="table">
        <div class="container">
            <el-table :data="tableData" border class="table">
                <el-table-column prop="time" label="时间"  min-width ="32%" align="center">
                </el-table-column>
                <el-table-column prop="operator" label="操作"  min-width ="32%" align="center">
                </el-table-column>
                <el-table-column prop="ip" label="ip" align="center"  min-width ="36%" >
                </el-table-column>
            </el-table>
            <el-row :gutter="20">
              <el-col :span="6" :offset="15">
                <div class="grid-content bg-purple pagination">
                  <el-pagination background @current-change="handleCurrentChange" layout="prev, pager, next" :total="total" :page-size="5">
                  </el-pagination>
                </div></el-col>
            </el-row>
        </div>
    </div>
</template>
<script>
import {searchUserdaily} from '../../api/api'
var moment = require('moment');
    export default {
        name: 'basetable',
        data() {
            return {
                tableData: [],
                cur_page: 1,
                total:null
            }
        },
        created() {
           this.getUserdaily();
        },
        methods: {
            // 分页导航
            handleCurrentChange(val) {
                this.cur_page = val;
                console.log(this.cur_page);
                this.getUserdaily();
            },
            getUserdaily(){
              const user = sessionStorage.getItem('user');
              searchUserdaily({username:user,page:this.cur_page}).then(res=>{
                let {result,total} = res;
                result.forEach(item => {
                  item.time = moment(item.time).format("YYYY-MM-DD HH:mm:ss");
                });
                this.tableData = result;
                this.total = total;
                console.log(res);
              });
            }
        }
    }

</script>

<style lang="scss" >
    .table{
        width:88.3%;
        font-size: 14px;
        margin:50px;
    }
   
    .el-table--enable-row-hover .el-table__body tr:hover>td{
    background-color: white !important;
    }

</style>

